﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Sesseion_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["MySessionId"] == null)
        { 
            // create cookie
            string sessionId = Guid.NewGuid().ToString();
            Response.SetCookie(new HttpCookie("MySessionId", sessionId));
        }
    }

    // set session
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sessionId = Request.Cookies["MySessionId"].Value;
        IDictionary<string, object> session = SessionMgr.GetSession(sessionId);
        session["ServerData"] = 123;
    }

    // get session
    protected void Button2_Click(object sender, EventArgs e)
    {
        string sessionId = Request.Cookies["MySessionId"].Value;
        IDictionary<string, object> session = SessionMgr.GetSession(sessionId);
        this.Label1.Text = session["ServerData"].ToString();
    }
}